import { rank_type } from "../../../../shared/interface";
import { player } from "../player";

export class user_log {
    /**
    * 玩家移动探索了多少个格子
    */
    private log_move_cont: number = 0;
    // 挂机时长
    log_onhoon_time: number = 0;
    // kill enemy
    log_kill_enemy_cont: number = 0;
    // 捕捉宠物次数
    log_pet_catch_cont: number = 0;
    // 宝箱获得次数
    log_opengiftbox: number = 0
    // 委托次数
    log_entrustTask_cont: number = 0;
    // boss击杀次数
    log_boss_kill_cont: number = 0;
    sign_cont: number = 0;
    sign_last_time: number = 0;
    /**
     * 新手任务完成耗时
     */
    newBie_endTime: number = 0;
    /**
     * 每日任务完成次数
     */
    everdayTask_cont: number = 0;
    /**
 * 每周任务完成次数
 */
    everweekTask_cont: number = 0;
    // 钓鱼记录
    private fishing_cont: number = 0;
    // 砍树次数
    private chopping_cont:number = 0;
    private _parent:player;
    constructor(data: any,parent:player) {
        if (data) {
            for (const key in data) {
                if (typeof (this[key]) != 'undefined') {
                    this[key] = data[key]
                }
            }
        }
        this._parent = parent;
    }
    add(key: rank_type, val: number) {
        let now = 0;
        switch (key) {
            case rank_type.砍树次数:
                this.chopping_cont += val;
                now = this.chopping_cont;
            break;
            case rank_type.boss击杀次数:
                this.log_boss_kill_cont += val;
                now = this.log_boss_kill_cont;
                break;
            case rank_type.步数:
                this.log_move_cont += val;
                now = this.log_move_cont;
                break;
            case rank_type.捕捉宠物成功次数:
                this.log_pet_catch_cont += val;
                now = this.log_pet_catch_cont;
                break;
            case rank_type.宝箱成功打开次数:
                this.log_opengiftbox += val;
                now = this.log_opengiftbox;
                break;
            case rank_type.挂机时长:
                this.log_onhoon_time += val;
                now = this.log_onhoon_time;
                break;
            case rank_type.击杀怪物数量:
                this.log_kill_enemy_cont += val;
                now = this.log_kill_enemy_cont;
                
                break;
            case rank_type.委托完成次数排行榜:
                this.log_entrustTask_cont += val;
                now = this.log_entrustTask_cont;
                break;
            case rank_type.签到次数:
                this.sign_cont += val;
                now = this.sign_cont;
                break;
            case rank_type.新手任务完成耗时:
                this.newBie_endTime += val;
                now = this.newBie_endTime;
                break;
            case rank_type.每日任务完成次数:
                this.everdayTask_cont += val;
                now = this.everdayTask_cont;
                break;
            case rank_type.每周任务完成次数:
                this.everweekTask_cont += val;
                now = this.everweekTask_cont;
                break;
            case rank_type.钓鱼总斤数:
                this.fishing_cont += val;
                now = this.fishing_cont;
                break;
            default:
                break;
        }
        this._parent.rankLog(key,now)
        return now;
    }
}